#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/wait.h>
#include <string.h>
#include <unistd.h>

#include "utility.h"

#define MAXLINE 1024

void executionScriptCommand(char *command)
{
    system(command);
    return;
    int rc = 0;
    FILE *fp;
    char result_buf[MAXLINE];

    if (null == command)
    {
        printf("(null == command\n");
        return;
    }
    //usleep(100);
    //printf("(command=%s\n", command);
    fp = popen(command, "r");
    if (null == fp)
    {
        /* code */
        perror("popen() fail\n");
        return;
    }
    while (fgets(result_buf, sizeof(result_buf), fp) != null)
    {
        /* code */
        if ('\n' == result_buf[strlen(result_buf) - 1])
        {
            /* code */
            result_buf[strlen(result_buf) - 1] = 0;
            printf("command output=%s\n", result_buf);
        }
        
    }
    rc = pclose(fp);
    if (-1 == rc)
    {
        /* code */
        perror("close fail\n");
        return;
    }
    usleep(100);
    //printf("command end, status=%d, returnValue=%d\n", rc, WEXITSTATUS(rc));
    return;
}

void delay_ms(int ms){
    usleep(ms * 1000);
}